package com.cms.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.cms.entity.base.BaseDivField;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * Entity - 表单字段
 * 
 * 
 * 
 */
@SuppressWarnings("serial")
@EqualsAndHashCode(callSuper = false)
@TableName("cms_div_field")
public class DivField extends BaseDivField {
	
    /**
     * 表单
     */
	@TableField(exist=false)
	@JSONField(serialize=false)
    private Div div;
    
    
	/**
	 * 获取表单
	 * 
	 * @return 表单
	 */
	public Div getDiv(){
	    if(div == null){
			Map<String,Object> map = SqlRunner.db().selectOne("select * from cms_div where id={0}",getDivId());
			div = JSON.parseObject(JSON.toJSONString(map), Div.class);
	    }
		return div;
	}
	

}
